import { Injectable } from '@angular/core';
import {Subject} from 'rxjs/Subject';
import {Observable} from 'rxjs/Observable';

@Injectable()
export class MessageService {
  // Observable子类
  private subject = new Subject();
  constructor() { }
  // 登录
  str = '登录';
  // 购物车数组
  prouducts = [];
  getMessage(): Observable<any> {
    console.log(this.subject);
    return this.subject.asObservable();
  }
  // 发送购物车物品数量
  sendMessage(num) {
    this.subject.next(num);
  }
  // 发送购物车商品信息
  sendProduct(obj) {
    this.subject.next(obj);
  }

}
